
//中心扩展算法
class Solution1 {
    public int countSubstrings(String s) {
        int count = 0;
        int i = 0;
        int n = s.length();
        while (i < s.length()) {
            //奇数个
            int l = i - 1, r = i + 1;
            while (l >= 0 && r < n && s.charAt(l) == s.charAt(r)) {
                l--;
                r++;
                count++;
            }
            //偶数个
            l = i;
            r = i + 1;
            while (l >= 0 && r < n && s.charAt(l) == s.charAt(r)) {
                l--;
                r++;
                count++;
            }
            i++;
            count++;
        }

        return count;
    }
}

//动态规划
class Solution2 {
    public int countSubstrings(String s) {
        int n = s.length();
        boolean[][] dp = new boolean[n][n];
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i; j < n; j++) {
                if (s.charAt(i) == s.charAt(j)) {
                    if (i == j || i + 1 == j) {
                        dp[i][j] = true;
                    } else if (dp[i + 1][j - 1]) {
                        dp[i][j] = true;
                    }
                }
            }
        }

        int count = 0;
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i; j < n; j++) {
                if (dp[i][j]) {
                    count++;
                }
            }
        }
        return count;
    }
}


class Solution3 {
    public String longestPalindrome(String s) {
        int n = s.length();
        int[][] dp = new int[n][n];
        for(int i = n-1; i>=0; i--) {
            for(int j = i; j<n; j++) {
                if(s.charAt(i) == s.charAt(j)) {
                    if(i == j) {
                        dp[i][j] = 1;
                    }else if(i+1 == j) {
                        dp[i][j] = 2;
                    }else if(dp[i+1][j-1]!=0) {
                        dp[i][j] = dp[i+1][j-1] + 1;
                    }
                }
            }
        }

        int l = 0, r = 0, cnt = 0;
        for(int i = n-1; i>=0; i--) {
            for(int j = i; j<n; j++) {
                if(dp[i][j] > cnt) {
                    cnt = dp[i][j];
                    l = i; r = j;
                }
            }
        }

        return s.substring(l,r+1);
    }
}

class Solution {
    public boolean checkPartitioning(String s) {
        int n = s.length();
        boolean[][] dp = new boolean[n][n];
        for (int i = n - 1; i >= 0; i--) {
            for (int j = i; j < n; j++) {
                if (s.charAt(i) == s.charAt(j)) {
                    if (i == j || i + 1 == j) {
                        dp[i][j] = true;
                    } else if (dp[i + 1][j - 1]) {
                        dp[i][j] = true;
                    }
                }
            }
        }
        //[0,i][i+1,j][j+1,n]
        for(int i = 1; i<n;i++) {
            for(int j = i+1;j < n; j++) {
                if(dp[0][i] && dp[i+1][j] && dp[j+1][n-1]) {
                    return true;
                }
            }
        }

        return false;
    }
}



public class Test {
    public static void main(String[] args) {
        long start=1;
        String s="202320232023";
        long end= Long.parseLong(s);
        long sum=0;
        long cj=1;
        while (start<=end){
            cj*=start;
            cj%=1000000000;
            sum+=cj;
            sum%=1000000000;
            start++;
            //if (start>40)
                //System.out.println(sum);
        }
        System.out.println(sum);
    }
}